package cn.audit.service.institution;

import cn.audit.bean.dto.UserCorrelation;
import cn.audit.bean.pojo.AuditInstitution;
import cn.audit.repository.institution.InstitutionRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 李忆枫
 * @Date: 2019/5/19 12:26
 */
@Service
public class InstitutionService {

    @Resource
    private InstitutionRepository institutionRepository;

    public List<AuditInstitution> findAll() {
        return institutionRepository.findAll();
    }

    public List<UserCorrelation> findAuditInstitutionAll() {
        return institutionRepository.findAuditInstitutionAll();
    }

    public List<AuditInstitution> findBySuperior(Long superior) {
        return institutionRepository.findBySuperior(superior);
    }

    public AuditInstitution findAuditInstitutionById(Long id) {
        return institutionRepository.findAuditInstitutionById(id);
    }

    public void save(AuditInstitution auditInstitution) {
        institutionRepository.save(auditInstitution);
    }

    /**
     * 批量删除
     *
     * @param ids
     */
    @Transactional(rollbackFor = Exception.class)
    public void BatchRemove(List<Long> ids) {
        institutionRepository.BatchRemove(ids);
    }

    @Transactional(rollbackFor = Exception.class)
    public void batchUpdate(String code, String auditname, Long id) {
        institutionRepository.batchUpdate(code, auditname, id);
    }

}
